<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="True">

<?python
from multiproject.core.permissions import CQDEPermissionStore
from multiproject.core.util import env_id
?>
        <div id="userProfileSummary">
            <py:with vars="item = message and message or discussion.topic;
                           username = item.author;
                           user = conf.getUserStore().getUser(username);
                           permissionstore = CQDEPermissionStore(env_id(req.base_path[1:]));
                           usergroups = (user != None) and permissionstore.get_user_project_groups(username) or [];
                           userpermissions = (user != None) and permissionstore.get_user_permissions(username) or [];
                           fullname = (user != None) and user.getDisplayName() or '';
                           userDispName = 17 > len(fullname) and fullname or fullname[:17]+'...'">

                <!--! Display name -->
                <span id="userName"><a href="${conf.url_home_path}/user/${username}">${userDispName}</a></span>
                <div id="roles">
                <!--! Role -->
                <py:choose>
                	<py:when test="username == 'anonymous'">
                		<strong id="role">Not registered user</strong><br/>
                	</py:when>
                    <py:when test="len(usergroups) > 0">
                        <div py:for="groupname in usergroups">
                          <strong id="role">$groupname</strong><br/>
                        </div>
                    </py:when>
                    <py:when test="len(usergroups) == 0">
                        <strong id="role">Registered user</strong><br/>
                    </py:when>
                    <py:otherwise>

                    </py:otherwise>
                </py:choose>
                </div>
                <!--! Icon -->
                <div id="userIcon">
                    <img py:if="user" src="${user.getAvatarUrl(36)}" alt="${user.username}'s avatar" />
                    <img py:if="not user" src="${conf.theme_htdocs_location}/images/no_icon.gif" alt="no avatar" />
                </div>
                <!--! Join date -->
                <!--! Posts -->

                <div id="userInfo">
                    <br />
                    <div>

                        <strong id="postcount">Posts:</strong>
                        <span>${discussion.msg_counts[username]}</span><br />
                        <py:if test="'DISCUSSION_MODERATE' in userpermissions">
                            <strong id="role">Moderator</strong><br/>
                        </py:if>
                    </div>
                </div>
            </py:with>
        </div>

</html>
